import dayjs from "dayjs";

// 下载图片
const downloadImg = (
  href: string,
  name: string = dayjs().format("YYYY-MM-DD HH:mm:ss")
) => {
  return new Promise((res) => {
    const aDom = document.createElement("a");
    aDom.href = href;
    aDom.download = name;
    aDom.click();
    aDom.remove();
    res(true);
  });
};

export { downloadImg };
